<template>
<div v-loading="loading">
  <div class="appeal_header">
    <div class="header_left">
      <a href="javascript:;">
        <img src="../assets/images/logo.png" class="logo">
      </a>
    </div>
  </div>
  <div class="login">
    <div class="loginPass">
      <div id="code" class="loginImg"></div>
      <div>请使用微信扫描二位码登录</div>
    </div>
  </div>
</div>
</template>
<script>

require('../assets/js/jquery.qrcode.min.js')


export default {
  name: 'login',
  data () {
    return{
      loading:true
    }
  },
  methods: {
    getQrcode() {
      const _this = this;
      this.post(this.jajaxUrl, {
        method: 'getservicemanagerlogininfo',
        isweixin: 1
      },function(r){

        $("#code").qrcode({
          render: "canvas",
          width: 260,
          height: 260,
          text: r.url,
          foreground: '#111'
        });

        _this.loading = false

       _this.axios.post(_this.jloadUrl, {
          id: r.clientid
        }).then((res)=>{
          let logininfo = res;
          _this.axios.post(_this.jholdUrl, {
            origin: 'WarmAppealService',
            method:'getcustype',
            company:res.company
          }).then((m)=>{
            let custypeName;
            let custype;
            if(m.Data.CusType == 0){
              custypeName = '无软件'
            }else if(m.Data.CusType == 1){
              custypeName = '收费'
            }else if(m.Data.CusType == 2){
              custypeName = '客服'
            }else if(m.Data.CusType == 3){
              custypeName = '收费&客服'
            }
            logininfo.custypeName = custypeName;
            logininfo.custype = m.Data.CusType;
            localStorage.loginInfo = JSON.stringify(logininfo);
            _this.$router.push('/home')
          })
        })
      })
    }
  },
  created() {
    this.getQrcode();
  }
}

</script>
